<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    iframe1
    <iframe src="./02iframe2.html" width="400px" height="400px"></iframe>
    <script>
        var myName = 'iframe1';
        var iframe = document.getElementsByTagName('iframe')[0];
        iframe.onload = function() {
                console.log(iframe);
                // 通过contentWindow获取iframe的window对象
                console.log(iframe.contentWindow);
                console.log(iframe.contentWindow.myName);
            }
            // 通过parent获得引用该页面的父级
        console.log(window.parent);
        console.log(window.parent.myName);
        console.log('---------------------------------');
    </script>
</body>

</html>